<template>
  <div class="navbar">
    <el-row>
      <el-col :span="8">
        <div class="logo">
          <el-link href="javascript:void(0);"> 物联网创新实训平台</el-link>
        </div>
      </el-col>
      <el-col :span="8">
         <!--
        <div class="nav-center">
          <ul class="nav-center-item">
            <el-popover placement="bottom" trigger="hover" :width="750">
              <template #reference>
                <div>
                  课程
                  <el-icon>
                    <arrow-down />
                  </el-icon>
                </div>
              </template> -->
              <!-- 自己填充内容 -->
              <!-- 最外层包裹控制内部整体间距 -->
              <!-- <div class="">
                <p style="color: rgb(153, 153, 153); margin-left: 20px">
                  黑发不知勤学早，白首方悔读书迟
                </p>
                <div
                  class=""
                  v-for="(item, index) in headerCourses"
                  :key="index"
                > -->
                  <!-- 分层处理，后面使用循环解决多层问题，包括，【小项目名，item名 ，对应链接】 -->
                  <!-- <p class="category-title">{{ item.categoryName }}</p>
                  <div class="category">
                    <div
                      class="category-item"
                      v-for="(deepItem, deepIndex) in item.categoryItem"
                      :key="deepIndex"
                      @click="goto(deepItem.name)"
                    >
                      {{ deepItem.name }}
                    </div>
                  </div>
                </div>
              </div>
            </el-popover>
          </ul>
          <ul class="nav-center-item" @click="goSchool()">
            学校
          </ul>
          <ul class="nav-center-item">
            <a href="http://localhost:8088/document">文档</a>
          </ul>
          <ul class="nav-center-item">
            <a href="http://114.55.126.125/">练习</a>
          </ul>
        </div> -->
      </el-col>
      <el-col :span="8">
        <div class="right_box">
          <div>
            <el-input
              type="text"
              v-model="selectMessage"
              :clearable="true"
              placeholder="搜索感兴趣的课程"
            ></el-input>
          </div>
          <div class="userCenter">
            <avatar></avatar>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script >
import Avatar from "@/components/myComponent/avatar.vue";
import { ArrowDown } from "@element-plus/icons-vue";
export default {
  components: {
    ArrowDown,
    Avatar,
  },
  // 数据源
  data() {
    return {
      // 顶部搜索框内容绑定
      selectMessage: "",
      //顶部课程数据展示结构
      headerCourses: [
        {
          categoryName: "大学",
          categoryItem: [
            {
              name: "计算机科学",
              id: "1001",
            },
            {
              name: "物联网",
              id: "1002",
            },
          ],
        },
        {
          categoryName: "中学",
          categoryItem: [
            {
              name: "高中物理",
              id: "2001",
            },
            {
              name: "高中生物",
              id: "2002",
            },
            {
              name: "高中化学",
              id: "2003",
            },
          ],
        },
        {
          categoryName: "早教",
          categoryItem: [
            {
              name: "科学",
              id: "3001",
            },
            {
              name: "艺术",
              id: "3002",
            },
          ],
        },
      ],
    };
  },
  //生命周期函数---
  mounted() {},
  //基本方法
  methods: {
    goto(deepItem) {
      this.$router.push({
        name: "course",
        query: {
          categoryName: deepItem,
        },
      });
    },
    goSchool() {
      alert("学校模块待完善");
    },
    personalInfor() {
      this.$router.push({
        path: "/user/center/information",
      });
    },
  },
  //计算类型方法和其他方法的区别：有缓存。以内存换时间，适用于频繁使用的计算
  computed() {},
};
</script>

<style   scoped>
a {
  text-decoration: none;
}
.navbar {
  width: 100%;
  height: 100%;
  top: 0;
  background: #fff;
}
.el-row {
  width: 100%;
  height: 100%;
}
.el-col {
  display: flex;
  align-items: center; /* 垂直居中 */
  justify-content: center;
}
.right_box {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.userCenter {
  margin-left: 20px;
  font-size: 14px;
  cursor: pointer;
}
.userCenter:hover {
  color: rgb(0, 204, 126);
}
.el-link::before {
  content: "";
  width: 50px;
  height: 35px;
  background-size: contain;
  background-repeat: no-repeat;
  background-image: url("../assets/images/onlinelearing.png");
}

.el-link {
  font-size: 25px;
  color: black;
}
.nav-center {
  display: flex;
  justify-content: center;
  align-content: center;
}
.nav-center-item {
  cursor: pointer;
}

.nav-center-item:hover {
  color: rgb(0, 204, 126);
}
.nav-center-item a {
  color: rgb(44, 62, 80);
}
.nav-center-item a:hover {
  color: rgb(0, 204, 126);
}
.category-title {
  font-size: 18px;
  font-weight: bolder;
  margin-left: 20px;
}
.category {
  display: flex;
  flex-wrap: wrap;
}
.category-item {
  /* 元素标签内：内容居中-》先设置一个div的宽高，使用text-align水平居中；再使用line-height上下居中即可（line-height设置的高度需跟div的高度一致） */
  text-align: center;
  line-height: 40px;
  height: 40px;
  width: 130px;
  margin-left: 20px;
  margin-bottom: 10px;
  background-color: rgb(245, 245, 245);
  border-radius: 10px;
  cursor: pointer;
}
.category-item:hover {
  color: rgb(32, 206, 108);
  background-color: rgb(229, 249, 238);
}
</style>